{"ast":null,"code":"/**\n * Cut input selection into 2 part and return text before selection start\n */\nexport function getBeforeSelectionText(input) {\n  var selectionStart = input.selectionStart;\n  return input.value.slice(0, selectionStart);\n}\n/**\n * Find the last match prefix index\n */\nexport function getLastMeasureIndex(text, prefix) {\n  return prefix.reduce(function (lastMatch, prefixStr) {\n    var lastIndex = text.lastIndexOf(prefixStr);\n    if (lastIndex > lastMatch.location) {\n      return {\n        location: lastIndex,\n        prefix: prefixStr\n      };\n    }\n    return lastMatch;\n  }, {\n    location: -1,\n    prefix: ''\n  });\n}\nfunction lower(char) {\n  return (char || '').toLowerCase();\n}\nfunction reduceText(text, targetText, split) {\n  var firstChar = text[0];\n  if (!firstChar || firstChar === split) {\n    return text;\n  }\n  // Reuse rest text as it can\n  var restText = text;\n  var targetTextLen = targetText.length;\n  for (var i = 0; i < targetTextLen; i += 1) {\n    if (lower(restText[i]) !== lower(targetText[i])) {\n      restText = restText.slice(i);\n      break;\n    } else if (i === targetTextLen - 1) {\n      restText = restText.slice(targetTextLen);\n    }\n  }\n  return restText;\n}\n/**\n * Paint targetText into current text:\n *  text: little@litest\n *  targetText: light\n *  => little @light test\n */\nexport function replaceWithMeasure(text, measureConfig) {\n  var measureLocation = measureConfig.measureLocation,\n    prefix = measureConfig.prefix,\n    targetText = measureConfig.targetText,\n    selectionStart = measureConfig.selectionStart,\n    split = measureConfig.split;\n  // Before text will append one space if have other text\n  var beforeMeasureText = text.slice(0, measureLocation);\n  if (beforeMeasureText[beforeMeasureText.length - split.length] === split) {\n    beforeMeasureText = beforeMeasureText.slice(0, beforeMeasureText.length - split.length);\n  }\n  if (beforeMeasureText) {\n    beforeMeasureText = \"\".concat(beforeMeasureText).concat(split);\n  }\n  // Cut duplicate string with current targetText\n  var restText = reduceText(text.slice(selectionStart), targetText.slice(selectionStart - measureLocation - prefix.length), split);\n  if (restText.slice(0, split.length) === split) {\n    restText = restText.slice(split.length);\n  }\n  var connectedStartText = \"\".concat(beforeMeasureText).concat(prefix).concat(targetText).concat(split);\n  return {\n    text: \"\".concat(connectedStartText).concat(restText),\n    selectionLocation: connectedStartText.length\n  };\n}\nexport function setInputSelection(input, location) {\n  input.setSelectionRange(location, location);\n  /**\n   * Reset caret into view.\n   * Since this function always called by user control, it's safe to focus element.\n   */\n  input.blur();\n  input.focus();\n}\nexport function validateSearch(text, props) {\n  var split = props.split;\n  return !split || text.indexOf(split) === -1;\n}\nexport function filterOption(input, _ref) {\n  var _ref$value = _ref.value,\n    value = _ref$value === void 0 ? '' : _ref$value;\n  var lowerCase = input.toLowerCase();\n  return value.toLowerCase().indexOf(lowerCase) !== -1;\n}","map":{"version":3,"names":["getBeforeSelectionText","input","selectionStart","value","slice","getLastMeasureIndex","text","prefix","reduce","lastMatch","prefixStr","lastIndex","lastIndexOf","location","lower","char","toLowerCase","reduceText","targetText","split","firstChar","restText","targetTextLen","length","i","replaceWithMeasure","measureConfig","measureLocation","beforeMeasureText","concat","connectedStartText","selectionLocation","setInputSelection","setSelectionRange","blur","focus","validateSearch","props","indexOf","filterOption","_ref","_ref$value","lowerCase"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/rc-mentions/es/util.js"],"sourcesContent":["/**\n * Cut input selection into 2 part and return text before selection start\n */\nexport function getBeforeSelectionText(input) {\n  var selectionStart = input.selectionStart;\n  return input.value.slice(0, selectionStart);\n}\n/**\n * Find the last match prefix index\n */\nexport function getLastMeasureIndex(text, prefix) {\n  return prefix.reduce(function (lastMatch, prefixStr) {\n    var lastIndex = text.lastIndexOf(prefixStr);\n    if (lastIndex > lastMatch.location) {\n      return {\n        location: lastIndex,\n        prefix: prefixStr\n      };\n    }\n    return lastMatch;\n  }, {\n    location: -1,\n    prefix: ''\n  });\n}\nfunction lower(char) {\n  return (char || '').toLowerCase();\n}\nfunction reduceText(text, targetText, split) {\n  var firstChar = text[0];\n  if (!firstChar || firstChar === split) {\n    return text;\n  }\n  // Reuse rest text as it can\n  var restText = text;\n  var targetTextLen = targetText.length;\n  for (var i = 0; i < targetTextLen; i += 1) {\n    if (lower(restText[i]) !== lower(targetText[i])) {\n      restText = restText.slice(i);\n      break;\n    } else if (i === targetTextLen - 1) {\n      restText = restText.slice(targetTextLen);\n    }\n  }\n  return restText;\n}\n/**\n * Paint targetText into current text:\n *  text: little@litest\n *  targetText: light\n *  => little @light test\n */\nexport function replaceWithMeasure(text, measureConfig) {\n  var measureLocation = measureConfig.measureLocation,\n    prefix = measureConfig.prefix,\n    targetText = measureConfig.targetText,\n    selectionStart = measureConfig.selectionStart,\n    split = measureConfig.split;\n  // Before text will append one space if have other text\n  var beforeMeasureText = text.slice(0, measureLocation);\n  if (beforeMeasureText[beforeMeasureText.length - split.length] === split) {\n    beforeMeasureText = beforeMeasureText.slice(0, beforeMeasureText.length - split.length);\n  }\n  if (beforeMeasureText) {\n    beforeMeasureText = \"\".concat(beforeMeasureText).concat(split);\n  }\n  // Cut duplicate string with current targetText\n  var restText = reduceText(text.slice(selectionStart), targetText.slice(selectionStart - measureLocation - prefix.length), split);\n  if (restText.slice(0, split.length) === split) {\n    restText = restText.slice(split.length);\n  }\n  var connectedStartText = \"\".concat(beforeMeasureText).concat(prefix).concat(targetText).concat(split);\n  return {\n    text: \"\".concat(connectedStartText).concat(restText),\n    selectionLocation: connectedStartText.length\n  };\n}\nexport function setInputSelection(input, location) {\n  input.setSelectionRange(location, location);\n  /**\n   * Reset caret into view.\n   * Since this function always called by user control, it's safe to focus element.\n   */\n  input.blur();\n  input.focus();\n}\nexport function validateSearch(text, props) {\n  var split = props.split;\n  return !split || text.indexOf(split) === -1;\n}\nexport function filterOption(input, _ref) {\n  var _ref$value = _ref.value,\n    value = _ref$value === void 0 ? '' : _ref$value;\n  var lowerCase = input.toLowerCase();\n  return value.toLowerCase().indexOf(lowerCase) !== -1;\n}"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,SAASA,sBAAsB,CAACC,KAAK,EAAE;EAC5C,IAAIC,cAAc,GAAGD,KAAK,CAACC,cAAc;EACzC,OAA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